$(() => {
    let query = location.search.split("=")[1];
    console.log("query =>", query);
    let carousel_item = $(".carousel-inner");
    let carousel_indicators = $(".carousel-indicators");
    $.ajax({
        url: 'https://m.youxiake.com/api/m/product/detail',
        type: 'GET',
        data: {
            pid: query,
            spm: 'eyJmcm9tIjoiMTMwOSIsIm9yaWdpbmFsX2lkIjowfQ',
            oid: 0
        },
        beforeSend: function(){
            $(".price_box").css("display","none");
        },
        success: function(data){
            console.log(data);
            let info = data.data.product;
            let ele = '';
            let btn = '';
            info.flash_pic.map((v, i) => {
                if(i == 0){
                    ele = `
                        <div class="carousel-item active">
                            <img src="${v}" class="d-block w-100" alt="...">
                        </div>
                    `;               
                    btn = `<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="${i}" class="active" aria-current="true" aria-label="Slide ${i+1}"></button>`;
                }else{
                    ele = `
                        <div class="carousel-item">
                            <img src="${v}" class="d-block w-100" alt="...">
                        </div>
                    `;
                    btn = `<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="${i}" aria-label="Slide ${i+1}"></button>`;
                }
                $(".loading").css("display","none");
                $(ele).appendTo(carousel_item);
                $(btn).appendTo(carousel_indicators);
            })
            $(".price").html(info.adultprice);
            $(".title").html(info.product_name);
            $(".desc").html(info.sub_name);
            $(data.data.productOutdoorLevel.popupContent).appendTo($(".level"))
            $(".price_box").css("display","block");
        }
    })
   
})